package pl.marcindziedzic.ticketstack.tests;

import java.util.List;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class StackPage extends Page {

	@FindBy(id = "ticketDesc")
	private WebElement ticketDesc;
	
	@FindBy(name = "tickets")
	private List<WebElement> tickets;

	public StackPage(WebDriver driver) {
		super(driver);
  }

	public StackPage get() {
		driver.get("http://localhost:8081/ticket-stack-0.0.1-SNAPSHOT/");
		return this;
  }

	public void put(String desc) {
		ticketDesc.sendKeys(desc);
		ticketDesc.submit();
  }

	public boolean contains(String desc) {
		
		for (WebElement ticket : tickets) {
	    if (desc.equals(ticket.getText())) {
	      return true;
      }
    }
		
		
	  return false;
  }

	

}
